package c.h.a.e0;

import android.app.Activity;
import android.app.AppOpsManager;
import android.content.Context;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Process;
import androidx.fragment.app.Fragment;
import b.f.h;
import b.i.b.f;
import b.l.a.g;

/* compiled from: PermissionUtils */
public final class a {
    public static final h<String, Integer> a;

    static {
        h hVar = new h(8);
        a = hVar;
        hVar.put("android.permission.USE_SIP", Integer.valueOf(9));
        hVar.put("com.android.voicemail.permission.ADD_VOICEMAIL", Integer.valueOf(14));
        Integer valueOf = Integer.valueOf(16);
        hVar.put("android.permission.READ_CALL_LOG", valueOf);
        hVar.put("android.permission.WRITE_CALL_LOG", valueOf);
        hVar.put("android.permission.READ_EXTERNAL_STORAGE", valueOf);
        hVar.put("android.permission.BODY_SENSORS", Integer.valueOf(20));
        valueOf = Integer.valueOf(23);
        hVar.put("android.permission.SYSTEM_ALERT_WINDOW", valueOf);
        hVar.put("android.permission.WRITE_SETTINGS", valueOf);
    }

    public static boolean a(Context context, String str) {
        int i = VERSION.SDK_INT;
        String str2 = null;
        Integer num = (Integer) a.getOrDefault(str, null);
        boolean z = false;
        boolean z2 = true;
        Object obj = (num == null || i >= num.intValue()) ? 1 : null;
        if (obj == null) {
            return true;
        }
        if (i >= 23) {
            if ("Xiaomi".equalsIgnoreCase(Build.MANUFACTURER)) {
                if (i >= 23) {
                    str2 = AppOpsManager.permissionToOp(str);
                }
                if (str2 != null) {
                    if (((AppOpsManager) context.getSystemService("appops")).noteOp(str2, Process.myUid(), context.getPackageName()) == 0 && f.T(context, str) == 0) {
                        z = true;
                    }
                    z2 = z;
                }
                return z2;
            }
        }
        try {
            if (f.T(context, str) == 0) {
                z = true;
            }
        } catch (RuntimeException unused) {
        }
        return z;
    }

    public static boolean b(Context context, String... strArr) {
        for (String a : strArr) {
            if (!a(context, a)) {
                return false;
            }
        }
        return true;
    }

    public static boolean c(Activity activity, String... strArr) {
        for (String str : strArr) {
            int i = b.i.b.a.b;
            if (VERSION.SDK_INT >= 23 ? activity.shouldShowRequestPermissionRationale(str) : false) {
                return true;
            }
        }
        return false;
    }

    public static boolean d(Fragment fragment, String... strArr) {
        for (String str : strArr) {
            g gVar = fragment.s;
            if (gVar != null ? gVar.o(str) : false) {
                return true;
            }
        }
        return false;
    }

    public static void e(Context context) {
        c.h.a.m0.h.n(context, context.getPackageName());
    }

    public static boolean f(int... iArr) {
        if (iArr.length == 0) {
            return false;
        }
        for (int i : iArr) {
            if (i != 0) {
                return false;
            }
        }
        return true;
    }
}
